#include <iostream>
#include "json.h"
#include "json_private.h"
using namespace std;

int main()
{
	JSON_OBJ obj;
	obj.read("json.json");

	int size = obj.var.size();
	for (int i = 0; i < size; i++)
	{
		JSON_VAR out = obj.var[i];
		cout << out.name << ' ' << (int)out.type << ' ';
		if (out.type == JSON_TSTR)
		{
			cout << *(string *)out.p;
		}
		else if (out.type == JSON_TBOOL)
		{
			if (*(bool *)out.p == 1)
			{
				cout << VTRUE;
			}
			else
			{
				cout << VFALSE;
			}
		}
		else if (out.type == JSON_TNUM)
		{
			cout << *(JSON_NUM *)out.p;
		}
		else if (out.type == JSON_TARR)
		{
			JSON_ARR *nums = (JSON_ARR *)out.p;
			for (int j = 0; j < nums->size(); j++)
			{
				if ((*nums)[j].type == JSON_TSTR)
				{
					cout << (*nums)[j].name << ' ';
					string *p = (string *)(*nums)[j].p;
					cout << *p << endl;
				}
			}
		}
		cout << endl;
	}

	return 0;
}
